package com.itzxx.huazhun.ui.collection.read

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.util.TimeUtils
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.itzxx.huazhun.data.model.ProbeStateInfo
import com.itzxx.huazhun.databinding.ItemRecordBinding
import com.itzxx.huazhun.data.model.RecordBean
import com.itzxx.huazhun.data.model.RecordChildBean
import com.itzxx.huazhun.databinding.ItemReadCollectionDataBinding
import com.itzxx.huazhun.databinding.ItemTestingNewBuildProbeBinding
import com.itzxx.library_base_ktx.ext.util.toDateStr

/**
 * Desc:
 *
 * Author: zhangxiaoxiao
 * Date: 2024/7/4 10:42
 * Updater:
 * Update Time:
 * Update Comments:
 */
class ReadCollectionDataAdapter : BaseQuickAdapter<ProbeStateInfo, ReadCollectionDataAdapter.VH>() {

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val binding: ItemReadCollectionDataBinding= ItemReadCollectionDataBinding.inflate(LayoutInflater.from(parent.context), parent, false),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: ProbeStateInfo?) {
        item?.run {
            holder.binding.dataBean = this
            when (state){
                0 -> {
                    holder.binding.state.text = "空"
                }

                1 -> {
                    holder.binding.state.text = "就绪"
                }

                2 -> {
                    holder.binding.state.text = "采集中"
                }

                3 -> {
                    holder.binding.state.text = "读取完成"
                }
            }

            item.probeTestingInfo?.let {
                holder.binding.time.text = "${  item.probeTestingInfo?.recordStartTime}000".toLong().toDateStr("yyyy-MM-dd HH:mm")
            }
        }

    }
}